package org.jprogger.myworld.api.client;

import org.jprogger.myworld.api.app.AppContext;
import org.jprogger.myworld.api.service.AudioService;
import org.jprogger.myworld.api.service.FriendService;
import org.jprogger.myworld.api.service.NotificationService;
import org.jprogger.myworld.api.service.PaymentService;
import org.jprogger.myworld.api.service.PhotoService;
import org.jprogger.myworld.api.service.StreamService;
import org.jprogger.myworld.api.service.UserService;
import org.jprogger.myworld.api.service.WidgetService;

public class ApiClient {

	private static ApiClient apiClient;
	
	private AppContext context;
	
	
	private ApiClient(AppContext context) {
		this.context = context;
	}
	
	public synchronized AppContext getContext() {
		return context;
	}
	
	public synchronized void setContext(AppContext context) {
		this.context = context;
	}
	
	public synchronized static ApiClient getApiClient(AppContext context) {
		
		if (apiClient == null) 
		{
			apiClient = new ApiClient(context);
		}
		return apiClient;
	}
	
	public AudioService getAudioService() {
		return new AudioService(getContext());
	}
	
	public FriendService getFriendService() {
		return new FriendService(getContext());
	}
	
	public NotificationService getNotificationService() {
		return new NotificationService(getContext());
	}
	
	public PaymentService getPaymentService() {
		return new PaymentService(getContext());
	}
	
	public PhotoService getPhotoService() {
		return new PhotoService(getContext());
	}
	
	public StreamService getStreamService() {
		return new StreamService(getContext());
	}
	
	public UserService getUserService() {
		return new UserService(getContext());
	}
	
	public WidgetService getWidgetService() {
		return new WidgetService(getContext());
	}
}
